<template>
  <div class="app-container client-user-container">
    <!-- 搜索和操作区域合并 -->
    <el-card class="search-operation-card" shadow="hover">
      <div class="card-header">
        <h3 class="card-title">用户搜索与操作</h3>
      </div>
      
      <!-- 搜索区域 -->
      <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="80px" class="search-form">
        <el-row :gutter="20">
          <el-col :span="5">
            <el-form-item label="账号" prop="username">
              <el-input
                v-model="queryParams.username"
                placeholder="请输入账号"
                clearable
                @keyup.enter="handleQuery"
              />
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="昵称" prop="nickname">
              <el-input
                v-model="queryParams.nickname"
                placeholder="请输入昵称"
                clearable
                @keyup.enter="handleQuery"
              />
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="手机号" prop="mobile">
              <el-input
                v-model="queryParams.mobile"
                placeholder="请输入手机号"
                clearable
                @keyup.enter="handleQuery"
              />
            </el-form-item>
          </el-col>
          <el-col :span="9">
            <div class="search-actions">
              <el-button type="primary" icon="Search" @click="handleQuery" class="search-btn">搜索</el-button>
              <el-button icon="Refresh" @click="resetQuery" class="reset-btn">重置</el-button>
            </div>
          </el-col>
        </el-row>
      </el-form>
      
      <!-- 操作按钮区域 -->
      <div class="operation-section">
        <el-row :gutter="15" class="operation-row">
          <el-col :span="1.5">
            <el-button
              type="primary"
              plain
              icon="Plus"
              @click="handleAdd"
              v-hasPermi="['clientUser:clientUser:add']"
              class="operation-btn primary-btn"
            >新增</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="success"
              plain
              icon="Edit"
              :disabled="single"
              @click="handleUpdate"
              v-hasPermi="['clientUser:clientUser:edit']"
              class="operation-btn success-btn"
            >修改</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              plain
              icon="Delete"
              :disabled="multiple"
              @click="handleDelete"
              v-hasPermi="['clientUser:clientUser:remove']"
              class="operation-btn danger-btn"
            >删除</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="warning"
              plain
              icon="Download"
              @click="handleExport"
              v-hasPermi="['clientUser:clientUser:export']"
              class="operation-btn warning-btn"
            >导出</el-button>
          </el-col>
          <div class="toolbar-wrapper">
            <right-toolbar v-model:showSearch="showSearch" @queryTable="getList" class="toolbar-right"></right-toolbar>
          </div>
        </el-row>
      </div>
    </el-card>

    <!-- 表格区域 -->
    <el-card class="table-card" shadow="hover">
      <div class="card-header">
        <h3 class="card-title">用户列表</h3>
        <div class="table-header-actions">
          <span class="result-count">共 {{ total }} 条记录</span>
        </div>
      </div>
      <el-table 
        v-loading="loading" 
        :data="clientUserList" 
        @selection-change="handleSelectionChange"
        class="client-user-table"
        stripe
        highlight-current-row
        :header-cell-style="{background: '#fafafa', color: '#2d3a4f'}"
      >
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="用户ID" align="center" prop="id" width="80" />
        <el-table-column label="头像" align="center" width="100">
          <template #default="scope">
            <el-avatar 
              :src="scope.row.avatar || '/images/avatar/default.png'" 
              size="large" 
              @click="handleChangeAvatar(scope.row)"
              class="user-avatar"
            ></el-avatar>
          </template>
        </el-table-column>
        <el-table-column label="账号" align="center" prop="username" width="180">
          <template #default="scope">
            <div class="username-cell" style="justify-content: center;">
              <span>{{ scope.row.username }}</span>
              <el-tag 
                v-if="scope.row.id === 1" 
                type="success" 
                size="small" 
                class="special-tag"
              >
                作者
              </el-tag>
              <el-tag 
                v-else-if="scope.row.id === 2" 
                type="warning" 
                size="small" 
                class="special-tag"
              >
                机器人
              </el-tag>
              <el-tag 
                v-else-if="scope.row.id === 3" 
                type="warning" 
                size="small" 
                class="special-tag"
              >
                演示账户
              </el-tag>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="昵称" align="center" prop="nickname" width="150">
          <template #default="scope">
            <div class="nickname-cell" style="justify-content: center;">
              <span>{{ scope.row.nickname }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="手机号" align="center" prop="mobile" width="200" />
        <el-table-column label="邮箱" align="center" prop="email" width="200" />
        <el-table-column label="性别" align="center" prop="sex" width="80">
          <template #default="scope">
            <dict-tag :options="sys_user_sex" :value="scope.row.sex"/>
          </template>
        </el-table-column>
        <el-table-column label="状态" align="center" prop="status" width="100">
          <template #default="scope">
            <dict-tag 
              :options="user_status" 
              :value="scope.row.status"
              :class="scope.row.status === 1 ? 'yes-tag' : 'no-tag'"
            />
          </template>
        </el-table-column>
        <el-table-column label="创建时间" align="center" prop="createTime" width="150">
          <template #default="scope">
            <span class="create-time">{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="最后登录时间" align="center" prop="lastLoginTime" width="120">
          <template #default="scope">
            <span class="login-time">{{ parseTime(scope.row.lastLoginTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180">
          <template #default="scope">
            <div class="action-buttons">
              <el-tooltip 
                content="修改用户信息" 
                placement="top"
              >
                <el-button 
                  link 
                  type="primary" 
                  icon="Edit" 
                  @click="handleUpdate(scope.row)" 
                  v-hasPermi="['clientUser:clientUser:edit']" 
                  class="table-action-btn edit-btn"
                >
                  修改
                </el-button>
              </el-tooltip>
              <el-tooltip 
                :content="scope.row.id === 1 || scope.row.id === 2 || scope.row.id === 3 ? '系统特殊用户不可删除' : '删除用户'" 
                placement="top"
              >
                <el-button 
                  link 
                  type="danger" 
                  icon="Delete" 
                  @click="handleDelete(scope.row)" 
                  v-hasPermi="['clientUser:clientUser:remove']" 
                  class="table-action-btn delete-btn"
                  :disabled="scope.row.id === 1 || scope.row.id === 2 || scope.row.id === 3"
                >
                  删除
                </el-button>
              </el-tooltip>
            </div>
          </template>
        </el-table-column>
      </el-table>
      
      <pagination
        v-show="total>0"
        :total="total"
        v-model:page="queryParams.pageNum"
        v-model:limit="queryParams.pageSize"
        @pagination="getList"
        class="pagination-container"
      />
    </el-card>

    <!-- 添加或修改用户信息对话框 -->
    <el-dialog  v-model="open" width="700px" append-to-body class="client-user-dialog">
      <div class="dialog-header">
        <h3 class="dialog-title">{{ title }}</h3>
      </div>
      <el-form ref="clientUserRef" :model="form" :rules="rules" label-width="100px" class="client-user-form">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="账号" prop="username">
              <el-input v-model="form.username" placeholder="请输入账号" class="form-input" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="昵称" prop="nickname">
              <el-input v-model="form.nickname" placeholder="请输入昵称" class="form-input" />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="手机号" prop="mobile">
              <el-input v-model="form.mobile" placeholder="请输入手机号" class="form-input" />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="邮箱" prop="email">
              <el-input v-model="form.email" placeholder="请输入邮箱" class="form-input" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="性别" prop="sex">
              <el-select v-model="form.sex" placeholder="请选择性别" style="width: 100%;" class="form-select">
                <el-option
                  v-for="dict in sys_user_sex"
                  :key="dict.value"
                  :label="dict.label"
                  :value="parseInt(dict.value)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="状态" prop="status">
              <el-radio-group v-model="form.status" class="form-radio-group">
                <el-radio
                  v-for="dict in user_status"
                  :key="dict.value"
                  :label="parseInt(dict.value)"
                >{{dict.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="个性签名" prop="signature">
              <el-input v-model="form.signature" placeholder="请输入个性签名" type="textarea" :rows="2" class="form-textarea" />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-form-item label="头像" prop="avatar">
          <div class="upload-container">
            <el-upload
              class="avatar-uploader"
              :http-request="customUpload"
              :show-file-list="false"
              :on-success="handleAvatarSuccess"
              :before-upload="beforeAvatarUpload"
            >
              <img v-if="form.avatar" :src="form.avatar" class="avatar" />
              <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
            </el-upload>
            <div class="upload-tip">点击上传头像图片</div>
          </div>
        </el-form-item>
        
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="IP地址" prop="ip">
              <el-input v-model="form.ip" placeholder="请输入IP地址" class="form-input" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="IP来源" prop="ipLocation">
              <el-input v-model="form.ipLocation" placeholder="请输入IP来源" class="form-input" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="登录系统" prop="os">
              <el-input v-model="form.os" placeholder="请输入登录系统" class="form-input" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="浏览器" prop="browser">
              <el-input v-model="form.browser" placeholder="请输入浏览器" class="form-input" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="最后登录时间" prop="lastLoginTime">
              <el-date-picker
                v-model="form.lastLoginTime"
                type="date"
                value-format="YYYY-MM-DD"
                placeholder="请选择最后登录时间"
                style="width: 100%;"
                class="form-datepicker"
                disabled
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm" class="submit-btn">确 定</el-button>
          <el-button @click="cancel" class="cancel-btn">取 消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="ClientUser">
import { listClientUser, getClientUser, delClientUser, addClientUser, updateClientUser, uploadUserAvatar } from "@/api/clientUser/clientUser"
import { ElMessage } from 'element-plus'
import { Plus } from '@element-plus/icons-vue'

const { proxy } = getCurrentInstance()
const { user_status, sys_user_sex } = proxy.useDict('user_status', 'sys_user_sex')

const clientUserList = ref([])
const open = ref(false)
const loading = ref(true)
const showSearch = ref(true)
const ids = ref([])
const single = ref(true)
const multiple = ref(true)
const total = ref(0)
const title = ref("")

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    id: null,
    username: null,
    password: null,
    createTime: null,
    updateTime: null,
    status: null,
    ip: null,
    ipLocation: null,
    os: null,
    lastLoginTime: null,
    browser: null,
    nickname: null,
    avatar: null,
    mobile: null,
    email: null,
    sex: null,
    loginType: null,
    signature: null
  },
  rules: {
    username: [
      { required: true, message: "账号不能为空", trigger: "blur" }
    ],
    nickname: [
      { required: true, message: "昵称不能为空", trigger: "blur" }
    ],
    mobile: [
      { pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur" }
    ],
    email: [
      { type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"] }
    ]
  }
})

const { queryParams, form, rules } = toRefs(data)

/** 查询用户信息列表 */
function getList() {
  loading.value = true
  listClientUser(queryParams.value).then(response => {
    clientUserList.value = response.rows
    total.value = response.total
    loading.value = false
  })
}

// 取消按钮
function cancel() {
  open.value = false
  reset()
}

// 表单重置
function reset() {
  form.value = {
    id: null,
    username: null,
    password: null,
    createTime: null,
    updateTime: null,
    status: 0,
    ip: null,
    ipLocation: null,
    os: null,
    lastLoginTime: null,
    browser: null,
    nickname: null,
    avatar: null,
    mobile: null,
    email: null,
    sex: null,
    loginType: null,
    signature: null
  }
  proxy.resetForm("clientUserRef")
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1
  getList()
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef")
  handleQuery()
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.id)
  single.value = selection.length != 1
  multiple.value = !selection.length
}

/** 新增按钮操作 */
function handleAdd() {
  reset()
  open.value = true
  title.value = "添加用户信息"
}

/** 修改按钮操作 */
function handleUpdate(row) {
  reset();
  const _id = row.id || ids.value;
  getClientUser(_id).then(response => {
    form.value = response.data;
    open.value = true;
    title.value = "修改用户信息";
  });
}

/** 头像上传 */
const customUpload = (options) => {
  const { file, onSuccess, onError } = options
  
  // 调用上传API
  uploadUserAvatar(file)
    .then(response => {
      console.log('上传响应:', response)
      if (response.code === 200) { // 根据实际返回状态码调整
        // 保存返回的图片URL到表单中
        form.value.avatar = response.data
        onSuccess(response)
        ElMessage.success('上传成功')
      } else {
        ElMessage.error(response.msg || '上传失败')
        onError(new Error(response.msg || '上传失败'))
      }
    })
    .catch(error => {
      console.error('上传错误:', error)
      ElMessage.error('上传失败: ' + (error.message || '网络错误'))
      onError(error)
    })
}

const handleAvatarSuccess = (response, file) => {
  console.log('上传响应:', response);
  ElMessage.success('上传成功');
}

/** 清除头像 */
function clearAvatar() {
  form.value.avatar = '';
}

const beforeAvatarUpload = (rawFile) => {
  if (rawFile.size / 1024 / 1024 > 5) {
    ElMessage.error('头像图片大小不能超过 5MB!');
    return false;
  }
  return true;
}

/** 提交按钮 */
function submitForm() {
  proxy.$refs["clientUserRef"].validate(valid => {
    if (valid) {
      if (form.value.id != null) {
        updateClientUser(form.value).then(response => {
          proxy.$modal.msgSuccess("修改成功")
          open.value = false
          getList()
        })
      } else {
        addClientUser(form.value).then(response => {
          proxy.$modal.msgSuccess("新增成功")
          open.value = false
          getList()
        })
      }
    }
  })
}

/** 删除按钮操作 */
function handleDelete(row) {
  // 检查是否为特殊用户
  if (row.id === 1 || row.id === 2) {
    proxy.$modal.msgWarning(row.id === 1 ? "作者账户为系统特殊用户，不可删除" : "机器人账户为系统特殊用户，不可删除");
    return;
  }
  
  const _ids = row.id || ids.value;
  
  // 获取要删除的用户信息，如果是多选删除则显示选中的所有用户信息
  let userNames = '';
  if (row.username) {
    // 单个删除
    userNames = row.username;
  } else if (ids.value.length > 0) {
    // 多选删除，从列表中查找选中的用户信息
    const selectedUsers = clientUserList.value.filter(item => ids.value.includes(item.id));
    userNames = selectedUsers.map(item => item.username).join(', ');
  }
  
  proxy.$modal.confirm('是否确认删除用户"' + userNames + '"').then(function() {
    return delClientUser(_ids);
  }).then(() => {
    getList();
    proxy.$modal.msgSuccess("删除成功");
  }).catch(() => {});
}

/** 导出按钮操作 */
function handleExport() {
  proxy.download('clientUser/clientUser/export', {
    ...queryParams.value
  }, `clientUser_${new Date().getTime()}.xlsx`)
}

getList()
</script>

<style scoped>
.client-user-container {
  background: #f0f2f5;
  padding: 20px;
  min-height: calc(100vh - 84px);
}

.search-operation-card {
  margin-bottom: 20px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  border: 1px solid #e4e7ed;
  background: #ffffff;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid #e4e7ed;
  background-color: #ffffff;
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  color: #2d3a4f;
  margin: 0;
}

.search-form {
  padding: 20px;
  border-bottom: 1px solid #f0f0f0;
}

.search-actions {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  height: 100%;
  padding-top: 10px;
}

.search-btn {
  background: #409eff;
  border: none;
  color: white;
  border-radius: 6px;
  padding: 10px 20px;
  transition: all 0.3s ease;
}

.search-btn:hover {
  background: #66b1ff;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(64, 158, 255, 0.3);
}

.reset-btn {
  border-radius: 6px;
  padding: 10px 20px;
  background: #f4f4f5;
  border: 1px solid #dcdfe6;
  color: #606266;
  transition: all 0.3s ease;
}

.reset-btn:hover {
  background: #e9e9eb;
  transform: translateY(-2px);
}

.operation-section {
  padding: 20px;
}

.operation-row {
  display: flex;
  align-items: center;
}

.toolbar-wrapper {
  flex: 1;
  display: flex;
  justify-content: flex-end;
}

.operation-btn {
  border-radius: 6px;
  transition: all 0.3s ease;
  padding: 10px 15px;
  font-weight: 500;
  border: 1px solid transparent;
}

.operation-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.primary-btn {
  background: #409eff;
  color: white;
  border: none;
}

.primary-btn:hover {
  background: #66b1ff;
}

.success-btn {
  background: #67c23a;
  color: white;
  border: none;
}

.success-btn:hover {
  background: #85ce61;
}

.danger-btn {
  background: #f56c6c;
  color: white;
  border: none;
}

.danger-btn:hover {
  background: #f78989;
}

.warning-btn {
  background: #e6a23c;
  color: white;
  border: none;
}

.warning-btn:hover {
  background: #ebb563;
}

.toolbar-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.table-card {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  border: 1px solid #e4e7ed;
  background: #ffffff;
}

.table-header-actions {
  display: flex;
  align-items: center;
}

.result-count {
  font-size: 14px;
  color: #909399;
}

.client-user-table {
  width: 100%;
}

.client-user-table :deep(.el-table__header th) {
  background-color: #fafafa;
  color: #2d3a4f;
  font-weight: 600;
  padding: 12px 0;
}

.client-user-table :deep(.el-table__row:hover) {
  background-color: #f5f7fa;
}

.create-time,
.login-time {
  color: #8492a6;
  font-size: 13px;
}

.action-buttons {
  display: flex;
  justify-content: center;
  gap: 5px;
}

.table-action-btn {
  margin: 0 5px;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 4px;
}

.edit-btn {
  color: #409eff;
  background: #ecf5ff;
  border: 1px solid #b3d8ff;
  transition: all 0.3s ease;
}

.edit-btn:hover {
  background: #b3d8ff;
  color: #409eff;
  border-color: #409eff;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(64, 158, 255, 0.3);
}

.delete-btn {
  color: #f56c6c;
  background: #fef0f0;
  border: 1px solid #fbc4c4;
  transition: all 0.3s ease;
}

.delete-btn:hover {
  background: #fbc4c4;
  color: #f56c6c;
  border-color: #f56c6c;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(245, 108, 108, 0.3);
}

.pagination-container {
  padding: 20px 0;
  display: flex;
  justify-content: center;
}

.client-user-dialog {
  border-radius: 12px;
}

.dialog-header {
  padding: 15px 20px;
  border-bottom: 1px solid #e4e7ed;
  background-color: #f8f9fa;
}

.dialog-title {
  font-size: 18px;
  font-weight: 600;
  color: #2d3a4f;
  margin: 0;
}

.client-user-dialog :deep(.el-dialog__header) {
  display: none;
}

.client-user-form {
  padding: 20px;
}

.form-input,
.form-select,
.form-datepicker,
.form-textarea {
  width: 100%;
}

.upload-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.avatar-uploader {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: var(--el-transition-duration-fast);
  width: 178px;
  height: 178px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;
}

.avatar-uploader:hover {
  border-color: #409eff;
  background: #f0f8ff;
}

.avatar-uploader-icon {
  font-size: 36px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar {
  width: 178px;
  height: 178px;
  display: block;
  object-fit: cover;
  border-radius: 6px;
}

.upload-tip {
  margin-top: 10px;
  font-size: 12px;
  color: #8492a6;
}

.form-radio-group {
  display: flex;
  gap: 20px;
}

.submit-btn {
  border-radius: 6px;
  padding: 12px 24px;
  background: #409eff;
  border: none;
  color: white;
  font-weight: 500;
  transition: all 0.3s ease;
}

.submit-btn:hover {
  background: #66b1ff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(64, 158, 255, 0.4);
}

.cancel-btn {
  border-radius: 6px;
  padding: 12px 24px;
  background: #f4f4f5;
  border: 1px solid #dcdfe6;
  color: #606266;
  font-weight: 500;
  transition: all 0.3s ease;
}

.cancel-btn:hover {
  background: #e9e9eb;
  transform: translateY(-2px);
}

.yes-tag {
  background: #409eff !important;
  color: white !important;
  padding: 4px 12px !important;
  border-radius: 12px !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  border: none !important;
}

.no-tag {
  background: #d0d5dd !important;
  color: #606266 !important;
  padding: 4px 12px !important;
  border-radius: 12px !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  border: none !important;
}

.username-cell,
.nickname-cell {
  display: flex;
  align-items: center;
  gap: 5px;
}

.special-tag {
  margin-left: 5px;
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .client-user-container {
    padding: 15px;
  }
  
  .search-operation-card,
  .table-card {
    padding: 15px;
  }
  
  .client-user-table :deep(.el-table__column) {
    font-size: 12px;
  }
  
  .create-time,
  .login-time {
    font-size: 12px;
  }
  
  .operation-row {
    flex-wrap: wrap;
  }
  
  .operation-row .el-col {
    margin-bottom: 10px;
  }
}

@media (max-width: 992px) {
  .client-user-container {
    padding: 15px;
  }
  
  .search-form :deep(.el-col) {
    margin-bottom: 15px;
  }
  
  .search-actions {
    justify-content: flex-end;
  }
  
  .operation-row {
    padding: 15px 0;
  }
}

@media (max-width: 768px) {
  .client-user-container {
    padding: 10px;
  }
  
  .client-user-dialog {
    width: 95% !important;
    margin-top: 20px !important;
  }
  
  .client-user-form :deep(.el-col) {
    margin-bottom: 15px;
  }
  
  .card-header {
    padding: 12px 15px;
  }
  
  .card-title {
    font-size: 16px;
  }
  
  .search-form,
  .operation-section {
    padding: 15px;
  }
}
</style>